package com.smitish.vueblog.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smitish.vueblog.entity.Follow;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smitish.vueblog.vo.UserFollowerVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 关注表 Mapper 接口
 * </p>
 *
 * @author Smitish
 * @since 2020-12-07
 */
public interface FollowMapper extends BaseMapper<Follow> {

    @Select("SELECT m_follow.*,m_user.`avatar` as `from_user_avatar`,m_user.`username` as `from_user_name`,m_user.`description` as `fromUserDescription` FROM m_follow,m_user WHERE m_follow.from_user_id=m_user.id AND to_user_id = ${to_user_id} ORDER BY created_time DESC")
    List<UserFollowerVO> getUserFans(Page<UserFollowerVO> page, @Param("to_user_id") Long id);


    @Select("SELECT m_follow.*,m_user.`avatar` as `to_user_avatar`,m_user.`username` as `to_user_name`,m_user.`description` as `toUserDescription` FROM m_follow,m_user WHERE m_follow.to_user_id=m_user.id AND from_user_id = ${from_user_id} ORDER BY created_time DESC")
    List<UserFollowerVO> getUserFollower(Page<UserFollowerVO> page, @Param("from_user_id") Long id);

}
